package addon.w3.mdx.com;

import java.io.IOException;
import java.util.Vector;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
PREM						// [ParticleEmitter]
	long	nbytes;
	struct {
		long	nbytesi;
		long	nbytesikg;		// inclusive bytecount including KGXXs
		ASCII	Name;			(0x50 bytes)
		long	ObjectID;
		long	Parent; 		(0xFFFFFFFF if none)
		long	Flags;	    (bit20)	// +bit23(EmitterUsesMDL) +bit8(EmitterUsesTGA)
		(KGTR)
		(KGRT)
		(KGSC)
		float	EmissionRate;
		float	Gravity;
		float	Longitude;
		float	Latitidue;
		ASCII	ModelPath;		(0x100 bytes)
		long	???;			(0)
		float	LifeSpan;
		float	InitVelocity;
		(KPEV)
	} particleemitters[nprems];
 * @author madjk
 * not tested;
 */
public class MDXParticleEmitters extends MDXParentCOM {
	int length = -1;
	Vector pemitters = null;
	
	public String getTag() {
		return "PREM";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		int cntLength = 0;
		pemitters = new Vector();
		while(cntLength < length) {
			MDXParticleEmitterCOM mdcom = new MDXParticleEmitterCOM();
			mdcom.decode(ins);
			pemitters.add(mdcom);
			cntLength += mdcom.nbytesi;
			//System.out.println(" cntLength : "+cntLength);
			//debug( mdcom.toString() );
		}
		//debug( geosets.get( (geosets.size()-1) ).toString() );
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(pemitters != null && pemitters.size() > 0) sb.append("\n\tPEMITTERS[] : "+pemitters.size());
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}